use std::time::Duration;

use btleplug::{
    api::{Central as _, Manager as _, Peripheral as _, ScanFilter},
    platform::Manager,
};
use tokio::time;

#[tokio::main]
async fn main() -> btleplug::Result<()> {
    let manager = Manager::new().await?;
    let adapter_list = manager.adapters().await?;
    for adapter in adapter_list.iter() {
        adapter.start_scan(ScanFilter::default()).await?;
        time::sleep(Duration::from_secs(3)).await;
        let peripherals = adapter.peripherals().await?;
        for peripheral in peripherals {
            let properties = peripheral.properties().await?;
            if let Some(properties) = properties {
                println!("{:?}", properties.local_name);
            }
        }
    }
    Ok(())
}
